/**
 * Copyright (C) 2017-2018 pinganfang, Inc. All Rights Reserved.
 */
package com.pingan.haofang.searchcloud.api;


/**
 * 增量操作变化类型
 * @author huhailiang937
 * @date 2017年5月5日上午10:52:45
 * @since 1.0.0
 */
public enum OperateEnum {

    INSERT(1, "insert", "新增"), UPDATE(2, "update", "更新"), DELETE(3, "delete", "删除");

    private Integer id;
    /**
     * 类型的名称
     */
    private String type;

    /**
     * 类型描述
     */
    private String desc;

    private OperateEnum(Integer id, String type, String desc) {
        this.id = id;
        this.type = type;
        this.desc = desc;
    }

    /**
     * @return the type
     */
    public String getType() {
        return type;
    }

    /**
     * @param type the type to set
     */
    public void setType(String type) {
        this.type = type;
    }

    /**
     * @return the desc
     */
    public String getDesc() {
        return desc;
    }

    /**
     * @param desc the desc to set
     */
    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * @return the id
     */
    public Integer getId() {
        return id;
    }

    /**
     * @param id the id to set
     */
    public void setId(Integer id) {
        this.id = id;
    }
    
    public static OperateEnum getOperateByName(String opType) {
        for (OperateEnum op : OperateEnum.values()) {
            if (op.name().equalsIgnoreCase(opType)) {
                return op;
            }
        }
        
        throw new RuntimeException("do not support the opType [" + opType + "]");
    }
}
